/**
 * Created by zhangb on 2015/10/23.
 */

var walk_the_dom = function walk(node,func)
{
    //TODO func()
    func(node);
    node = node.firstChild;
    while(node)
    {
        walk(node,func);
        node = node.nextSibling;
    }
};

var getElementsByAttribute = function (att,value)
{
    var results = [];
    walk_the_dom(document.body,function(node)
    {
        var actual = node.nodeType === 1 && node.getAttribute(att);
        if(typeof actual === 'string' && (actual === value || typeof value !== 'string'))
        {
            results.push(node);
        }
    });
};

